package com.raptor.trustworthy.task;

import com.raptor.trustworthy.task.service.ScheduleJobService;
import javax.annotation.PostConstruct;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

@Component
public class TrustworthyTaskServletInitializer implements ApplicationRunner {

	private static final Logger log = LoggerFactory.getLogger(TrustworthyTaskServletInitializer.class);

	@Autowired
	private ScheduleJobService scheduleJobService;

	@Value(value = "${openTimeTask}")
	private String openTimeTask;

	@PostConstruct
	public void init() {
		log.info("init VsopTaskServletInitializer");
	}


	@Override
	public void run(ApplicationArguments args) throws Exception {
		log.info("vsop-task  initializer...");
		//初始化定时任务,读取定时任务标志参数，1表示定时任务系统，0业务系统，业务系统不加载定时任务
		if ("1".equals(openTimeTask)) {
			scheduleJobService.initJobs();
		}
	}
}
